package com.xuzmian.demo.kotlin


/**
 * 包服务类：提供包范围内的全局函数和属性。
 */

//不可变变量val类似于javafinal
val str: String = "你好"

//数组创建方式1
val arr1: Array<Int> = arrayOf(1, 2, 3)

//数组创建方式2：Array of int of size 5 with values [0, 1, 2, 3, 4]
var arr2 = IntArray(5, { it * 1 })

val list = listOf("a", "b", "c")

val positives = list.filter { x -> x != "a" }

val map = mapOf("xzm" to 18, "jounry" to 36, "hanli" to 3)


var multiLineTemplate = """
        --------多行字符输出--------
        |字符串模板变量:$str 
        |这是模板变量+转义符号'$'如何输出: ${'$'}9.99
        |这是模板表达式:${list.size}
        |---------
    """.replace("|", "")


fun test() {
    println(multiLineTemplate)
}

class PackageGlobalService {
    fun test() {
        println(multiLineTemplate)
    }
}